package com.compass.mobile.ui.viewModel

import androidx.lifecycle.MutableLiveData
import com.compass.mobile.framework.utils.TipsToast
import com.compass.mobile.models.Classify
import com.compass.mobile.models.Nurse
import com.compass.mobile.models.User
import com.compass.mobile.network.callback.IApiErrorCallback
import com.compass.mobile.network.manager.ApiManager
import com.compass.mobile.network.viewmodel.BaseViewModel
import com.google.gson.JsonObject

/**
 * Description： 护理viewmodel
 * Date:2024/5/29 16:06
 */
class NurseProjectViewModel : BaseViewModel() {


    val classifyLiveData = MutableLiveData<MutableList<Classify>?>()
    val nurseLiveData    = MutableLiveData<MutableList<Nurse>?>()
    val nurseDetailLiveData    = MutableLiveData<Nurse?>()

    fun getClassify() {
        launchUIWithResult(responseBlock = {
            ApiManager.api.getClassify()
        }, errorCall = object : IApiErrorCallback {
            override fun onError(code: Int?, error: String?) {
                TipsToast.showTips(error)
            }
        }, successBlock = {
            classifyLiveData.value = it
        })
    }

    fun getMoreNurse(classifyId: String) {
        launchUIWithResult(responseBlock = {
            ApiManager.api.getMoreNurse(classifyId)
        }, errorCall = object : IApiErrorCallback {
            override fun onError(code: Int?, error: String?) {
                TipsToast.showTips(error)

            }
        }, successBlock = {
            nurseLiveData.value = it

        })
    }


    fun geHotNurse() {
        launchUIWithResult(responseBlock = {
            ApiManager.api.geHotNurse("4")
        }, errorCall = object : IApiErrorCallback {
            override fun onError(code: Int?, error: String?) {
                TipsToast.showTips(error)

            }
        }, successBlock = {
            nurseLiveData.value = it

        })
    }

    fun geNurseDetail(id: String?) {
        launchUIWithResult(responseBlock = {
            ApiManager.api.geNurseDetail(id)
        }, errorCall = object : IApiErrorCallback {
            override fun onError(code: Int?, error: String?) {
                TipsToast.showTips(error)
            }
        }, successBlock = {
            nurseDetailLiveData.value = it

        })
    }
}